package T;

import java.util.Scanner;

public class StudentDemo {
    public static void main(String[] args) {
        Student.setStudent();
    }
}

class Student {
    private String name;
    private String id;
    private double java;
    private double html;
    private double javascript;
    private double sum;

    public Student() {
        super();
    }

    public Student(String name, String sno, double java, double mysql, double javaweb, double sum) {
        this.name = name;
        this.id = id;
        this.java = java;
        this.html = html;
        this.javascript = javascript;
        this.sum = sum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public double getJava() {
        return java;
    }

    public void setJava(double java) {
        this.java = java;
    }

    public double getHtml() {
        return html;
    }

    public void setHtml(double html) {
        this.html = html;
    }

    public double getJavascript() {
        return javascript;
    }

    public void setJavascript(double javascript) {
        this.javascript = javascript;
    }

    public double getSum() {
        return sum;
    }

    public void setSum(double sum) {
        this.sum = sum;
    }

    public static void setStudent() {
        Stu s0 = new Stu();

        Student[] sts = new Student[5];
        for (int i = 0; i < sts.length; i++) {
            sts[i] = s0.getStudent();
        }

        for (int i = 0; i < sts.length - 1; i++) {
            for (int j = i + 1; j < sts.length; j++) {
                if (sts[i].sum < sts[j].sum) {
                    Student temp = sts[i];
                    sts[i] = sts[j];
                    sts[j] = temp;
                }
            }
        }
        for (Student s : sts) {
            System.out.println(s);
        }
    }

    @Override
    public String toString() {
        return "Student [name=" + name + ", sno=" + id + ", java=" + java + ", mysql=" + html + ", javaweb=" + javascript
                + ", sum=" + sum + "]";
    }
}

class Stu extends Student {
    public Stu() {
        super();
    }

    public Stu(String name, String sno, double java, double mysql, double javaweb, double sum) {
        super(name, sno, java, mysql, javaweb, sum);
    }

    public Student getStudent() {
        Student s1 = new Student();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生姓名：");
        s1.setName(scanner.nextLine());
        System.out.println("请输入学生学号：");
        s1.setId(scanner.nextLine());
        System.out.println("请输入学生java成绩：");
        s1.setJava(scanner.nextDouble());
        System.out.println("请输入学生MySQL成绩：");
        s1.setHtml(scanner.nextDouble());
        System.out.println("请输入学生Javaweb成绩：");
        s1.setJavascript(scanner.nextDouble());
        s1.setSum(s1.getJava() + s1.getHtml() + s1.getJavascript());
        return new Student(s1.getName(), s1.getId(), s1.getJava(), s1.getHtml(), s1.getJavascript(), s1.getSum());
    }
}
